"""author: wenyao
   data: 2021/10/21
   project: cjh
"""

#########python数值类型 - 整型 ，浮点型， 复数
###############################整型
#python2   vs  python3
#python2整型分为：长整型（long）和整型
#python3只有整型
# [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux│[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
# 2                                              │Type "help", "copyright", "credits" or "license"
# Type "help", "copyright", "credits" or "license│ for more information.
# " for more information.                        │>>> a = 10
# >>> a = 10                                     │>>> type(a)
# >>> type(a)                                    │
# <type 'int'>                                   │<class 'int'>
# >>> a = 99999999999999999999999999999999       │>>> a = 99999999999999999999999999999999
# >>> type(a)                                    │>>> type(a)
# <type 'long'>                                  │<class 'int'>
# >>>                                            │>>>

####进制转换
# >>> a = 0b11
# >>> type(a)
# <class 'int'>
# >>> b = 0o11
# >>> type(b)
# <class 'int'>
# >>> c = 0x11
# >>> type(c)
# <class 'int'>
# >>> num1 = 100
# >>> bin(num1)
# '0b1100100'
# >>> type(bin(num1))
# <class 'str'>
# >>> oct(num1)
# '0o144'
# >>> hex(num1)
# '0x64'
# >>> result = bin(0o12)
# >>> print(result)
# 0b1010
# >>> type(result)
# <class 'str'>
# >>> int(0o11)
# 9
# >>> int("0o11")
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# ValueError: invalid literal for int() with base 10: '0o11'
# >>> int("0o11", base=8)
# 9
# >>> int("11")
# 11

#小练习
# fnum = input("please input your first number:")
# snum = input("please input your first number:")
# result = int(fnum) + int(snum)
# print("两数之和：",result)
#
# num = int(input("please input your number:"))
# print('该数的二进制为'+bin(num),'该数的八进制为'+oct(num),'该数的十六进制为'+hex(num))

##################################复数
#实部和虚部
# >>> a = -5 + 4j
# >>> type(a)
# <class 'complex'>
# >>> dir(a)  #查看对象的属性方法，如果有这个属性就可以通过 . 的方式去访问调用
# ['__abs__', '__add__', '__bool__', '__class__', '__delattr__', '__dir__',
# '__divmod__', '__doc__', '__eq__', '__float__', '__floordiv__',
# '__format__', '__ge__', '__getattribute__', '__getnewargs__',
# '__gt__', '__hash__', '__init__', '__init_subclass__',
# '__int__', '__le__', '__lt__', '__mod__', '__mul__',
# '__ne__', '__neg__', '__new__', '__pos__', '__pow__',
# '__radd__', '__rdivmod__', '__reduce__', '__reduce_ex__',
# '__repr__', '__rfloordiv__', '__rmod__', '__rmul__',
# '__rpow__', '__rsub__', '__rtruediv__', '__setattr__',
# '__sizeof__', '__str__', '__sub__', '__subclasshook__',
# '__truediv__', 'conjugate', 'imag', 'real']
# >>> a.imag  #获取虚部的内容，无论定义的时候是整型还是浮点型都会转换成浮点型进行存储
# 4.0
# >>> a.real  #获取实部的内容
# -5.0
# >>>

#################################浮点数
#float   double
#float不精确的
#decimal 精确的
#print()
# from decimal import Decimal
# mydec = Decimal("3.22")
# print(mydec, type(mydec))
# mydec2 = Decimal(3.22)
# print(mydec2)

# 3.22 <class 'decimal.Decimal'>
# 3.220000000000000195399252334027551114559173583984375

##############################字符串
# a = "abc"
# print(a)

#r标志 是输出原始字符串，不转义
# b = r"a\nb"
# print(b)

# print("a\\nb")
# print("\ta\"b")

#字符串切片索引
#str[start:end:step]
#1、确定步长step为正还是为负
#    为正 从左到右取值
#    为负  从右到左取值
#2、确定start和end的位置
#3、确定步长
# str1 = "abcdefghijk"
# print(str1[-9:8:2])
#
# print(str1[2:])
#
# print(str1[:7])
#
# print(str1[::-1])
#
# print(str1[4::-2])

#字符串的不可变的序列
# 一旦创造了一个字符串，就不能再改变它。
# print(str1[5])
# # str1[5] ="x"
# str1 = "abcdexghijk"

#字符串级连
# str2 = "aa""bbb"
# print(str2)

#字符串的运算
# str3 = "hello,"
# str4 = "world!"
# print(str3 + str4)
# print(str3*3)

#字符串的转换
# result = str(100)
# print(type(result), result)


